﻿using AutoMapper;
using KuaFu.CardIssuing.OpenApi.Args.MerchantFeeConfig;
using KuaFu.Extensions;
using KuaFu.Extensions.Base;
using KuaFu.Shared;
using KuaFu.Shared.CardIssuingPlatformService.Services.MerchantFeeConfig;
using Microsoft.AspNetCore.Mvc;

namespace KuaFu.CardIssuing.OpenApi.Controllers
{
    [Route("api/merchant_fee_config")]
    public class MerchantFeeConfigController : BaseApiController
    {
        public readonly IServiceProvider serviceProvider;
        private readonly UserInfo _userInfo;
        private readonly IMapper _mapper;

        public MerchantFeeConfigController(IServiceProvider serviceProvider, UserInfo userInfo, IMapper mapper)
        {
            this.serviceProvider = serviceProvider;
            _userInfo = userInfo;
            _mapper = mapper;
        }

        /// <summary>
        /// 获取商户费用
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        [HttpPost("get")]
        public async Task<ApiResult<GetMerchantFeeResult, Result.GetMerchantFeeResult>> GetAsync([FromBody] GetMerchantFeeArgs args)
        {
            var result = await serviceProvider.GetRequiredService<GetMerchantFeeService>().ExecuteAsync(new GetMerchantFeeArgument(_userInfo.GetMerhcantId(), args.Currency, args.CardProductId, args.FeeType, args.Amount));
            return new ApiResult<GetMerchantFeeResult, Result.GetMerchantFeeResult>(result,_mapper);
        }
    }
}
